<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>片段笔记！(有新鲜东西随时可能更新)：仅用于自己学习笔记 | HankChan&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="#### 页面请求URL为了避免跳转多次，在URL前加上当前web应用的context上下文路径：    ${pageContext.request.contextPath }/&amp;lt;/pre&amp;gt;     &amp;lt;/div&amp;gt;     &amp;lt;div id=&amp;quot;wmd-preview-section-21&amp;quot; class=&amp;quot;wmd-preview-section">
<meta property="og:type" content="article">
<meta property="og:title" content="片段笔记！(有新鲜东西随时可能更新)：仅用于自己学习笔记">
<meta property="og:url" content="http://hexo.hankchan.cn/2016/05/06/e7-89-87-e6-ae-b5-e7-ac-94-e8-ae-b0-ef-bc-81-e6-9c-89-e6-96-b0-e9-b2-9c-e4-b8-9c-e8-a5-bf-e9-9a-8f-e6-97-b6-e5-8f-af-e8-83-bd-e6-9b-b4-e6-96-b0-ef-bc-9a-e4-bb-85-e7-94-a8-e4-ba-8e-e8-87-aa-e5-b7-b1/index.html">
<meta property="og:site_name" content="HankChan&#39;s Blog">
<meta property="og:description" content="#### 页面请求URL为了避免跳转多次，在URL前加上当前web应用的context上下文路径：    ${pageContext.request.contextPath }/&amp;lt;/pre&amp;gt;     &amp;lt;/div&amp;gt;     &amp;lt;div id=&amp;quot;wmd-preview-section-21&amp;quot; class=&amp;quot;wmd-preview-section">
<meta property="og:updated_time" content="2017-05-26T02:13:23.615Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="片段笔记！(有新鲜东西随时可能更新)：仅用于自己学习笔记">
<meta name="twitter:description" content="#### 页面请求URL为了避免跳转多次，在URL前加上当前web应用的context上下文路径：    ${pageContext.request.contextPath }/&amp;lt;/pre&amp;gt;     &amp;lt;/div&amp;gt;     &amp;lt;div id=&amp;quot;wmd-preview-section-21&amp;quot; class=&amp;quot;wmd-preview-section">
  
    <link rel="alternate" href="/atom.xml" title="HankChan&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">HankChan&#39;s Blog</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">生活就像海洋</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://hexo.hankchan.cn"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-e7-89-87-e6-ae-b5-e7-ac-94-e8-ae-b0-ef-bc-81-e6-9c-89-e6-96-b0-e9-b2-9c-e4-b8-9c-e8-a5-bf-e9-9a-8f-e6-97-b6-e5-8f-af-e8-83-bd-e6-9b-b4-e6-96-b0-ef-bc-9a-e4-bb-85-e7-94-a8-e4-ba-8e-e8-87-aa-e5-b7-b1" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/05/06/e7-89-87-e6-ae-b5-e7-ac-94-e8-ae-b0-ef-bc-81-e6-9c-89-e6-96-b0-e9-b2-9c-e4-b8-9c-e8-a5-bf-e9-9a-8f-e6-97-b6-e5-8f-af-e8-83-bd-e6-9b-b4-e6-96-b0-ef-bc-9a-e4-bb-85-e7-94-a8-e4-ba-8e-e8-87-aa-e5-b7-b1/" class="article-date">
  <time datetime="2016-05-06T06:30:40.000Z" itemprop="datePublished">2016-05-06</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/未分类/">未分类</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      片段笔记！(有新鲜东西随时可能更新)：仅用于自己学习笔记
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <div id="wmd-preview-section-19" class="wmd-preview-section preview-content"><br><br>#### 页面请求URL为了避免跳转多次，在URL前加上当前web应用的context上下文路径：<br><br></div><br><div id="wmd-preview-section-20" class="wmd-preview-section preview-content"><br><br>    ${pageContext<span class="hljs-preprocessor">.request</span><span class="hljs-preprocessor">.contextPath</span> }/<code>&lt;/pre&gt;
    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-21&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    #### 在SpringMVC中处理URL请求参数中文乱码问题：

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-22&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;
    &lt;pre class=&quot;prettyprint&quot;&gt;</code><span class="hljs-annotation">@RequestMapping</span>(<span class="hljs-string">“/privateChat/{username}”</span>)<br>        <span class="hljs-keyword">public</span> ModelAndView <span class="hljs-title">privateChat</span>(HttpServletRequest request, HttpServletResponse response,<br>                @<span class="hljs-title">PathVariable</span>(“username”) String searchusername) <span class="hljs-keyword">throws</span> Exception{<br>            ModelAndView modelAndView = <span class="hljs-keyword">new</span> ModelAndView();<br>            modelAndView.setViewName(<span class="hljs-string">“privatechat”</span>);<br>            <span class="hljs-javadoc">/<strong><strong><em>*</em></strong></strong> 获取方式 <strong><strong><em>**</em></strong></strong>/</span><br>            <span class="hljs-keyword">byte</span> bb[];<br>            bb = searchusername.getBytes(<span class="hljs-string">“ISO-8859-1”</span>); <span class="hljs-comment">//以”ISO-8859-1”方式解析name字符串</span><br>            searchusername = <span class="hljs-keyword">new</span> String(bb, <span class="hljs-string">“UTF-8”</span>); <span class="hljs-comment">//再用”utf-8”格式表示name</span><br>            System.out.println(<span class="hljs-string">“输出的请求私聊参数：”</span> + searchusername);<br>            <span class="hljs-keyword">return</span> modelAndView;<br>     }<code>&lt;/pre&gt;
    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-23&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    #### 处理JSON;

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-24&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;
    &lt;pre class=&quot;prettyprint&quot;&gt;</code>@ResponseBody<br>    @RequestMapping(“/testJson”)<br>    public List<span class="hljs-tag">&lt;<span class="hljs-title">User</span>&gt;</span> testJson(){<br>        return userService.getAll();<br>    }<br><br>    <span class="hljs-tag">&lt;<span class="hljs-title">script</span>&gt;</span><span class="javascript"><br>    $(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span>{</span><br>        $(<span class="hljs-string">“#testJson”</span>).click(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span>{</span><br>            <span class="hljs-keyword">var</span> url = <span class="hljs-string">“this.href”</span>; <span class="hljs-comment">//&lt;a href=”testJson”&gt;&lt;/a&gt;</span><br>            <span class="hljs-keyword">var</span> args = {};<br>            $.post(url, args, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(datas)</span>{</span><br>                <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; datas.length; i++){<br>                    <span class="hljs-keyword">var</span> id = datas[i].id;<br>                    <span class="hljs-keyword">var</span> username = datas[i].username;<br>                    <span class="hljs-comment">//alert(id + “:” + username);</span><br>                }<br>            });<br>            <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;<br>        });<br>    })<br>    </span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span><code>&lt;/pre&gt;
    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-25&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    #### Maven项目解决报“java compiler level does not match the version of the installed java project facet”的错误：

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-26&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    ##### 方法1: 在该项目的本地目录下的setting配置中修改该文件：org.eclipse.wst.common.project.facet.core.xml 中的以下版本配置即可

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-27&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;
    &lt;pre class=&quot;prettyprint&quot;&gt;</code> <span class="hljs-tag">&lt;<span class="hljs-title">installed</span> <span class="hljs-attribute">facet</span>=<span class="hljs-value">“java”</span> <span class="hljs-attribute">version</span>=<span class="hljs-value">“1.8”</span>/&gt;</span> <code>&lt;/pre&gt;
    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-28&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    ##### 方法2: 更好的解决办法是在Eclipse新建maven项目后到项目的buildPath配置中找到Project Facets，然后配置该项目的Project Facets中的Java版本。

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-29&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;

    ##### 方法3： 在父项目的pom中的 &amp;lt; project &amp;gt; 节点下添加如下的依赖以配置编译环境。

    &lt;/div&gt;
    &lt;div id=&quot;wmd-preview-section-30&quot; class=&quot;wmd-preview-section preview-content&quot;&gt;
    &lt;pre class=&quot;prettyprint&quot;&gt;</code>  <span class="hljs-tag">&lt;<span class="hljs-title">build</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-title">finalName</span>&gt;</span>swift-base<span class="hljs-tag">&lt;/<span class="hljs-title">finalName</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-title">plugins</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-title">plugin</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-title">groupId</span>&gt;</span>org.apache.maven.plugins<span class="hljs-tag">&lt;/<span class="hljs-title">groupId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-title">artifactId</span>&gt;</span>maven-compiler-plugin<span class="hljs-tag">&lt;/<span class="hljs-title">artifactId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-title">version</span>&gt;</span>3.5.1<span class="hljs-tag">&lt;/<span class="hljs-title">version</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-title">configuration</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-title">source</span>&gt;</span>1.7<span class="hljs-tag">&lt;/<span class="hljs-title">source</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-title">target</span>&gt;</span>1.7<span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span><br>                <span class="hljs-tag">&lt;/<span class="hljs-title">configuration</span>&gt;</span><br>            <span class="hljs-tag">&lt;/<span class="hljs-title">plugin</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-title">plugins</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-title">build</span>&gt;</span><br><br></div>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://hexo.hankchan.cn/2016/05/06/e7-89-87-e6-ae-b5-e7-ac-94-e8-ae-b0-ef-bc-81-e6-9c-89-e6-96-b0-e9-b2-9c-e4-b8-9c-e8-a5-bf-e9-9a-8f-e6-97-b6-e5-8f-af-e8-83-bd-e6-9b-b4-e6-96-b0-ef-bc-9a-e4-bb-85-e7-94-a8-e4-ba-8e-e8-87-aa-e5-b7-b1/" data-id="cj359k3xe000mfwv7c6gk0tqi" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/05/10/ef-bc-88-e8-bd-ac-e8-bd-bd-e5-ad-a6-e4-b9-a0-ef-bc-89git-e5-9f-ba-e7-a1-80-e8-8e-b7-e5-8f-96-git-e4-bb-93-e5-ba-93/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          （转载学习）Git 基础 - 获取 Git 仓库
        
      </div>
    </a>
  
  
    <a href="/2016/05/04/springmvc-e5-86-99-e4-b8-80-e4-b8-aa-e8-be-93-e5-87-ba-e4-b8-bajackson-e6-a0-bc-e5-bc-8f-e5-a6-82xml-e3-80-81json-e7-9a-84api-e7-9a-84-e5-b0-8f-e7-ac-94-e8-ae-b0/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">SpringMVC写一个输出为Jackson格式(如xml、json)的api的小笔记</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Docker/">Docker</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Eclipse/">Eclipse</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Eclipse/Mybatis/">Mybatis</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Eclipse/Spring/">Spring</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Eclipse/分布式/">分布式</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Git/">Git</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Linux/">Linux</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Linux/Nginx/">Nginx</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Mybatis/">Mybatis</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Mybatis/Spring/">Spring</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Mybatis/Spring/SpringMVC/">SpringMVC</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Mybatis/SpringMVC/">SpringMVC</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Nginx/">Nginx</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Spring/">Spring</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/SpringMVC/">SpringMVC</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/分布式/">分布式</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/日志管理/">日志管理</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/未分类/">未分类</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">三月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/">五月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">四月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">三月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">二月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">一月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">十二月 2015</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2017/03/13/docker-e5-be-ae-e6-9c-8d-e5-8a-a1-e5-ae-b9-e5-99-a8-e5-8c-96-e5-bc-80-e5-8f-91-e6-8e-a2-e7-b4-a2/">Docker-微服务容器化开发探索</a>
          </li>
        
          <li>
            <a href="/2017/01/20/drds-e7-bb-93-e5-90-88mybatis-e8-a7-a3-e5-86-b3-e6-96-b9-e6-a1-88-e4-b8-8e-e8-a7-84-e8-8c-83/">DRDS结合Mybatis解决方案与规范</a>
          </li>
        
          <li>
            <a href="/2017/01/03/springmvc-thymeleaf-e5-bc-80-e5-8f-91-e6-8c-87-e5-8d-97-demo/">SpringMVC-Thymeleaf-开发指南-Demo</a>
          </li>
        
          <li>
            <a href="/2016/10/16/nginx-e4-bb-a3-e7-90-86-e6-9c-8d-e5-8a-a1-e5-99-a8-e6-96-b9-e5-bc-8f-e8-a7-a3-e5-86-b3-e5-ae-9e-e9-99-85-e5-bc-80-e5-8f-91-e4-b8-adajax-e8-af-b7-e6-b1-82-e7-9a-84-e8-b7-a8-e5-9f-9f-e9-97-ae-e9-a2-98/">Nginx代理服务器方式解决实际开发中Ajax请求的跨域问题</a>
          </li>
        
          <li>
            <a href="/2016/10/11/e5-b7-a5-e5-8e-82-e6-a8-a1-e5-bc-8f-e5-92-8c-e5-8d-95-e4-be-8b-e6-a8-a1-e5-bc-8f-e7-bb-93-e5-90-88-e5-ba-94-e7-94-a8-e7-9a-84-e5-9c-ba-e6-99-af-e6-80-9d-e8-80-83/">工厂模式和单例模式结合应用的场景思考</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2017 Hank Chan<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>